import { optionCommon } from './common'
import { ARCHIVES_TYPE, ARCHIVES_TYPE_LIST, ARCHIVES_FIRE_CLASSIFY, ARCHIVES_FIRE_CLASSIFY_LIST, ARCHIVES_EXPLODE_LIST } from '@/const/archives'
export default vm => {
    const { nickName, userId, dept: { deptName } } = vm.$store.getters.userInfo
    return {
        ...optionCommon,
        editBtn: false,
        delBtn: false,
        border: false,
        stripe: true,
        headerAlign: 'left',
        align: 'left',
        defaultExpandAll: false,
        selection: true,
        tip: false,
        dialogTop: '20',
        size: 'mini',
        maxHeight: '600',
        fixed: 'right',
        column: [
            {
                order: 1,
                label: '案卷名称',
                prop: 'name',
                search: true,
                html: true,
                span: 8,
                width: '308px',
                overHidden: true,
                fixed: 'left',
                formatter: val => {
                    if (val.doPerson && val.doOtherPerson) {
                        const isRelated = (
                            val.doOtherPerson + val.doPerson
                        ).includes(vm.$store.state.user.nickName)
                        return `<span style="color:${isRelated || ('' && '#67C23A')
                            }">${val.name}</span>`
                    } else {
                        return `<span style="color:'#67C23A')}">${val.name}</span>`
                    }
                }
            },
            {
                order: 1,
                label: '案卷编号',
                prop: 'code',
                span: 8,
                width: 160,
                rules: [
                    {
                        required: true,
                        message: "请输入案卷编号",
                        trigger: "blur"
                    }
                ],
                row: true
            },
            {
                order: 2,
                label: '案卷状态',
                prop: 'state',
                type: 'select',
                span: 8,
                dicData: [
                    { label: '未归档', value: '0' },
                    { label: '已归档', value: '1' }
                ],
                value: '0',
                search: true,
                slot: true
                // html: true,
                // formatter: (val) => {
                //   if (!val.$state) return ''
                //   const data = [{ color: 'red', label: '调查中' }, { color: 'blue', label: '已归档' }]
                //   return `<span><b style="color:">(${val.$state})</b></span>`
                // }
            },
            {
                order: 2,
                search: true,
                label: '程序类型',
                prop: 'archivesType',
                span: 8,
                disabled: true,
                slot: true,
                type: 'select',
                width: 90,
                dataType: 'number',
                value: ARCHIVES_TYPE.SIMPLE,
                dicData: ARCHIVES_TYPE_LIST
            },
            {
                order: 2,
                span: 8,
                label: '是否爆炸',
                prop: 'isExplode',
                type: 'switch',
                hide: true,
                value: 0,
                dicData: ARCHIVES_EXPLODE_LIST,
                dataType: 'number',
                change: e => {
                    // var prop = vm.findObject(vm.option.column, 'coordination')
                    // prop.display = !!parseFloat(e.value)
                }
            },
            {
                order: 3,
                span: 24,
                label: '火灾分类',
                prop: 'category',
                type: 'select',
                hide: true,
                dataType: 'number',
                value: ARCHIVES_FIRE_CLASSIFY.SIMPLE,
                dicData: ARCHIVES_FIRE_CLASSIFY_LIST,
                change: e => {
                    if (!e.value) {
                        vm.form.category = vm.form.archivesType
                    }
                    if (e.value == vm.form.archivesType) return
                    if (e.value || e.value == 0) {
                        vm.form.archivesType = e.value
                    }
                }
            },
            {
                order: 4,
                search: true,
                label: '起火对象',
                prop: 'fireName',
                search: true,
                span: 8,
                width: 120,
                value: '重新定义有限公司',
            },
            {
                order: 4,
                hide: true,
                label: '起火地点',
                prop: 'fireAddress',
                type: 'map',
                span: 8,
                // 高德初始化参数
                params: {
                    zoom: 10
                },
                dataType: 'string',
                formatter(row, value, label, column) {
                    if (value) {
                        const arr = value.split(',')
                        return arr[arr.length - 1]
                    } else {
                        return ''
                    }
                }
            },
            {
                order: 4,
                label: '起火天气',
                prop: 'weather',
                span: 8,
                value: '天气多云，南风4级，空气湿度6',
                hide: true,
                row: true
            },
            {
                order: 5,
                label: '详细地址',
                prop: 'address',
                value: '伟业路999号A栋601',
                span: 8,
                hide: true,
                row: true
            },
            {
                order: 6,
                label: '简单描述',
                prop: 'remark',
                span: 24,
                hide: true,
                row: true
            },
            {
                order: 7,
                label: '承办单位',
                prop: 'doOrg',
                span: 24,
                width: 180,
                value: deptName,
                row: true
            },
            {
                order: 8,
                search: true,
                label: '主办人',
                prop: 'doPerson',
                span: 8,
                type: 'select',
                dicData: [],
                value: userId,
                filterable: true,
                dataType: 'string',
                change: ({ value, column, item: cItem }) => {
                    const obj = column.dicData.find(item => item.value == value)
                    if (obj) {
                        vm.form.doOrg = obj.dept
                    }
                },
                formatter: val => {
                    return val.doPersonName
                },
                align:'center'
            },
            {
                order: 9,
                span: 8,
                label: '协办人',
                prop: 'doOtherPerson',
                type: 'select',
                multiple: true,
                filterable: true,
                // props: {
                //     label: 'nickName',
                //     value: 'userId',
                //     res: 'rows'
                // },
                // dicUrl: `/system/user/list?pageNum=1&pageSize=999&isDic=true`,
                dataType: 'string',
                formatter: val => {
                    return val.doOtherPersonName
                },
                align:'center'
            }, {
                order: 8,
                search: true,
                width: 160,
                label: '报警时间',
                prop: 'callTime',
                span: 8,
                type: 'datetime',
                format: 'yyyy-MM-dd HH:mm:ss',
                valueFormat: 'yyyy-MM-dd HH:mm:ss',
                defaultTime: '12:00:00',
                value: vm.parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'),
                align:'center'
            }, {
                order: 9,
                search: true,
                width: 160,
                label: '出警时间',
                prop: 'goTime',
                span: 8,
                type: 'datetime',
                format: 'yyyy-MM-dd HH:mm:ss',
                valueFormat: 'yyyy-MM-dd HH:mm:ss',
                defaultTime: '12:00:00',
                value: vm.parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'),
                align:'center'
            }, {
                order: 8,
                label: '出警车辆',
                prop: 'doCars',
                span: 8,
                type: 'input-number',
                controlsPosition: 'left',
                value: 5,
                align:'center'
            }, {
                order: 9,
                label: '出警人数',
                prop: 'doPersonCount',
                span: 8,
                type: 'input-number',
                controlsPosition: 'left',
                value: 10,
                align:'center'
            },
            {
                span: 12,
                label: '非消防管辖',
                prop: 'coordination',
                hide: true,
                formslot: true,
                display: false,
                align:'center'
            },
            {
                label: '创建时间',
                prop: 'createTime',
                hide: true,
                display: false,
                align:'center'
            },
            {
                width: 120,
                slot: true,
                label: '卷宗',
                prop: 'file',
                display: false,
                fixed: 'right',
                align:'center'
            }
        ]
    }
}
